home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14203 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  999 b 

  1. Path: imaginet.fr!usenet
  2. From: URBANY <systec@imaginet.fr>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Typecasting a class?  Help!
  5. Date: 29 Mar 1996 10:14:11 GMT
  6. Organization: ImagiNET
  7. Message-ID: <4jgd5j$1ld@avalon.imaginet.fr>
  8. References: <dkelly.828048898@maestro.inav.net>
  9. NNTP-Posting-Host: cyber25.imaginet.fr
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  14.  
  15. dkelly@blue.weeg.uiowa.edu (Dave Kelly) wrote:
  16. > ...
  17. >
  18. >But it doesn't work unless I do this:
  19. >
  20. >printf("clInteger is equal to %d\n", (int)clInteger);
  21. >
  22.  
  23. It doesn't work because printf has only one declared argument. printf prototype
  24. if (by memory) in printf(const char*, ...).
  25. So the compiler can't figure what is the type of your clInteger argument, and then 
  26. it can't cast it.
  27.  
  28. Secondly, in C++, it is better to use iostream << operators instead of printf. Then 
  29. the comiler knows how to do :
  30. cout << clInteger.
  31.  
  32. Hope this help
  33.  
  34. Nicolas CAILLAUD
  35.  
  36.  
  37.